package com.jdkreader.concurent.forkjoin;

import java.io.*;
import java.util.LinkedList;
import java.util.List;

/**
 * Fork/Join示例文件类
 *
 * @author zhaoyiwu
 * @create 2018-03-12 14:18
 **/
public class Document {

    private final List<String> lines;

    public Document(List<String> lines) {
        this.lines = lines;
    }


    public List<String> getLines() {
        return lines;
    }



    static Document fromFile(File file) throws IOException {

        List<String> lines=new LinkedList<String>();

        try(BufferedReader reader = new BufferedReader(new FileReader(file))){
             String line=reader.readLine();

             while(null != line){
                 lines.add(line);
                 line=reader.readLine();
            }

        }
       return new Document(lines);
    }
}
